﻿/*
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at 
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  
 */
using System;
using java = biz.ritter.javapi;

namespace biz.ritter.javapi.lang
{

    /**
     * Thrown when an assertion has failed.
     *
     * @since 1.4
     */
    public class AssertionError : Error {

        private static readonly long serialVersionUID = -5013299493970297370L;

        /**
         * Constructs a new {@code AssertionError} with no message.
         */
        public AssertionError() :base(){
        }

        /**
         * Constructs a new {@code AssertionError} with a message based on calling
         * {@link String#valueOf(Object)} with the specified object. If the object
         * is an instance of {@link Throwable}, then it also becomes the cause of
         * this error.
         * 
         * @param detailMessage
         *            the object to be converted into the detail message and
         *            optionally the cause.
         */
        public AssertionError(Object detailMessage) : base (detailMessage.ToString(),
                    (detailMessage is Throwable ? (Throwable) detailMessage
                            : null)){
        }

        /**
         * Constructs a new {@code AssertionError} with a message based on calling
         * {@link String#valueOf(boolean)} with the specified boolean value.
         * 
         * @param detailMessage
         *            the value to be converted into the message.
         */
        public AssertionError(bool detailMessage) : this (java.lang.StringJ.valueOf(detailMessage).ToString()){
        }

        /**
         * Constructs a new {@code AssertionError} with a message based on calling
         * {@link String#valueOf(char)} with the specified character value.
         * 
         * @param detailMessage
         *            the value to be converted into the message.
         */
        public AssertionError(char detailMessage):this(""+detailMessage) {
        }

        /**
         * Constructs a new {@code AssertionError} with a message based on calling
         * {@link String#valueOf(int)} with the specified integer value.
         * 
         * @param detailMessage
         *            the value to be converted into the message.
         */
        public AssertionError(int detailMessage):
            this(Integer.toString(detailMessage)){
        }

        /**
         * Constructs a new {@code AssertionError} with a message based on calling
         * {@link String#valueOf(long)} with the specified long value.
         * 
         * @param detailMessage
         *            the value to be converted into the message.
         */
        public AssertionError(long detailMessage) :
            this(Long.toString(detailMessage)){
        }

        /**
         * Constructs a new {@code AssertionError} with a message based on calling
         * {@link String#valueOf(float)} with the specified float value.
         * 
         * @param detailMessage
         *            the value to be converted into the message.
         */
        public AssertionError(float detailMessage) : 
            this(Float.toString(detailMessage)){
        }

        /**
         * Constructs a new {@code AssertionError} with a message based on calling
         * {@link String#valueOf(double)} with the specified double value.
         * 
         * @param detailMessage
         *            the value to be converted into the message.
         */
        public AssertionError(double detailMessage) : 
            this(Double.toString(detailMessage)){
        }
    }
}
